/**
 * copyright geolabs 2007
 * Exemple Toto class
 */
System.require("OctoXml");

Toto=Controler.extend();
Toto.define({
  newData: function(){
      //var tmp=new XmlToJson({xml:this.request.responseXML, root: "channel", loop: "item"});
      //tmp.createTree();
      var tmp=OctoXml.jsonFromElement(this.request.responseXML.getElementsByTagName('result')[0])['result']['trimestret'];
      document.body.appendChild(document.createElement("br"));
      document.body.innerHTML=OctoXml.dumpAsJson(tmp);
      var tmpOut={};
      document.body.innerHTML+=OctoXml.dumpAsJson(tmpOut);
      for(i in tmp){
	document.body.appendChild(document.createElement("br"));
	document.body.innerHTML+="\n\n*** "+tmp[i]['@id']+" ***\n";
	document.body.appendChild(document.createElement("br"));
	document.body.innerHTML+=OctoXml.dumpAsJson(((tmp[i].tuple instanceof Array)?tmp[i].tuple:Array(tmp[i].tuple)));
	tmpOut[tmp[i]['@id']]=((tmp[i].tuple instanceof Array)?tmp[i].tuple:Array(tmp[i].tuple));
      }
      document.body.appendChild(document.createElement("br"));
      document.body.innerHTML+=OctoXml.dumpAsJson(tmpOut);
      this.request=null;
    }
  });
